set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ox -Ob2 -Oi -Ot -Oy -GT -GL -Gy -Qpar -arch:AVX2 -openmp")
cmake_minimum_required(VERSION 3.16)

project(shapeMatch VERSION 0.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

#qt
set(CMAKE_PREFIX_PATH "C:/qt/qt6/6.6.3/msvc2019_64/lib/cmake/Qt6")
find_package(Qt6 REQUIRED COMPONENTS Core Quick)

#opencv
set(CMAKE_PREFIX_PATH "C:/opencv/opencv/build/x64/vc16/lib")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})



#set(COMMON_COMPILE_FLAGS "-fopenmp -Wall -Wno-sign-compare")


#include MIPP
include_directories (${INCLUDE_DIRECTORIES} "${CMAKE_CURRENT_SOURCE_DIR}/MIPP/")

# icp for refine
option(USE_CUDA "use cuda or not" OFF)

if(USE_CUDA)
set(CUDA_TOOLKIT_ROOT_DIR /usr/local/cuda-10.0)
add_definitions(-DCUDA_ON)
endif()

add_subdirectory(cuda_icp)




qt_standard_project_setup(REQUIRES 6.5)


# 添加QML和资源文件

qt_add_executable(shapeMatch
    main.cpp
    ImageProvider.h
    Backend.h
    matchResult.h
    Backend.cpp
    ImageProvider.cpp
    ${QML_FILES}
    line2Dup.h
    line2Dup.cpp
)

qt_add_qml_module(shapeMatch
    URI shapeMatch
    VERSION 1.0
    QML_FILES
        Main.qml
        RoiRectangle.qml
        SOURCES ImageProvider.cpp
        SOURCES ImageProvider.h
        RESOURCES resources.qrc
        SOURCES Backend.h
        SOURCES matchResult.h
        SOURCES Backend.cpp
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(shapeMatch PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.shapeMatch
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_link_libraries(shapeMatch
PRIVATE
    Qt6::Quick
    Qt6::Core
    ${OpenCV_LIBS}
    cuda_icp
)

include(GNUInstallDirs)
install(TARGETS shapeMatch
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)


    #windeployqt6.exe --qmldir C:\Users\hello\Desktop\qt\helloQml\shapeMatch C:\Users\hello\Desktop\qt\helloQml\shapeMatch\vsBuild\Release\shapeMatch.exe
